home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
os2
/
e33el2.zip
/
emacs
/
19.33
/
lisp
/
cal-china.el
< prev
next >
Wrap
Lisp/Scheme
|
1996-03-22
|
22KB
|
456 lines
;;; cal-china.el --- calendar functions for the Chinese calendar.
;; Copyright (C) 1995 Free Software Foundation, Inc.
;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
;; Keywords: calendar
;; Human-Keywords: Chinese calendar, calendar, holidays, diary
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; This collection of functions implements the features of calendar.el,
;; diary.el, and holidays.el that deal with the Chinese calendar. The rules
;; used for the Chinese calendar are those of Baolin Liu (see L. E. Doggett's
;; article "Calendars" in the Explanatory Supplement to the Astronomical
;; Almanac, second edition, 1992) for the calendar as revised at the beginning
;; of the Qing dynasty in 1644. The nature of the astronomical calculations
;; is such that precise calculations cannot be made without great expense in
;; time, so that the calendars produced may not agree perfectly with published
;; tables--but no two pairs of published tables agree perfectly either! Liu's
;; rules produce a calendar for 2033 which is not accepted by all authorities.
;; The date of Chinese New Year is correct from 1644-2051.
;; Comments, corrections, and improvements should be sent to
;; Edward M. Reingold Department of Computer Science
;; (217) 333-6733 University of Illinois at Urbana-Champaign
;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
;; Urbana, Illinois 61801
;;; Code:
(require 'lunar)
(defvar chinese-calendar-celestial-stem
["Jia" "Yi" "Bing" "Ding" "Wu" "Ji" "Geng" "Xin" "Ren" "Gui"])
(defvar chinese-calendar-terrestrial-branch
["Zi" "Chou" "Yin" "Mao" "Chen" "Si" "Wu" "Wei" "Shen" "You" "Xu" "Hai"])
(defvar chinese-calendar-time-zone
'(if (< year 1928)
(+ 465 (/ 40.0 60.0))
480)
"*Number of minutes difference between local standard time for Chinese
calendar and Coordinated Universal (Greenwich) Time. Default is for Beijing.
This is an expression in `year' since it changed at 1928-01-01 00:00:00 from
UT+7:45:40 to UT+8.")
(defvar chinese-calendar-location-name "Beijing"
"*Name of location used for calculation of Chinese calendar.")
(defvar chinese-calendar-daylight-time-offset 0
; The correct value is as follows, but the Chinese calendrical
; authorities do NOT use DST in determining astronomical events:
; 60
"*Number of minutes difference between daylight savings and standard time
for Chinese calendar. Default is for no daylight savings time.")
(defvar chinese-calendar-standard-time-zone-name
'(if (< year 1928)
"PMT"
"CST")
"*Abbreviated name of standard time zone used for Chinese calendar.")
(defvar chinese-calendar-daylight-time-zone-name "CDT"
"*Abbreviated name of daylight-savings time zone used for Chinese calendar.")
(defvar chinese-calendar-daylight-savings-starts nil
; The correct value is as follows, but the Chinese calendrical
; authorities do NOT use DST in determining astronomical events:
; '(cond ((< 1986 year) (calendar-nth-named-day 1 0 4 year 10))
; ((= 1986 year) '(5 4 1986))
; (t nil))
"*Sexp giving the date on which daylight savings time starts for Chinese
calendar. Default is for no daylight savings time. See documentation of
`calendar-daylight-savings-starts'.")
(defvar chinese-calendar-daylight-savings-ends nil
; The correct value is as follows, but the Chinese calendrical
; authorities do NOT use DST in determining astronomical events:
; '(if (<= 1986 year) (calendar-nth-named-day 1 0 9 year 11))
"*Sexp giving the date on which daylight savings time ends for Chinese
calendar. Default is for no daylight savings time. See documentation of
`calendar-daylight-savings-ends'.")
(defvar chinese-calendar-daylight-savings-starts-time 0
"*Number of minutes after midnight that daylight savings time starts for
Chinese calendar. Default is for no daylight savings time.")
(defvar chinese-calendar-daylight-savings-ends-time 0
"*Number of minutes after midnight that daylight savings time ends for
Chinese calendar. Default is for no daylight savings time.")
(defun chinese-zodiac-sign-on-or-after (d)
"Absolute date of first new Zodiac sign on or after absolute date d.
The Zodiac signs begin when the sun's longitude is a multiple of 30 degrees."
(let* ((year (extract-calendar-year
(calendar-gregorian-from-absolute d)))
(calendar-time-zone (eval chinese-calendar-time-zone))
(calendar-daylight-time-offset
chinese-calendar-daylight-time-offset)
(calendar-standard-time-zone-name
chinese-calendar-standard-time-zone-name)
(calendar-daylight-time-zone-name
chinese-calendar-daylight-time-zone-name)
(calendar-calendar-daylight-savings-starts
chinese-calendar-daylight-savings-starts)
(calendar-daylight-savings-ends
chinese-calendar-daylight-savings-ends)
(calendar-daylight-savings-starts-time
chinese-calendar-daylight-savings-starts-time)
(calendar-daylight-savings-ends-time
chinese-calendar-daylight-savings-ends-time))
(floor
(calendar-absolute-from-astro
(solar-date-next-longitude
(calendar-astro-from-absolute d)
30)))))
(defun chinese-new-moon-on-or-after (d)
"Absolute date of first new moon on or after absolute date d."
(let* ((year (extract-calendar-year
(calendar-gregorian-from-absolute d)))
(calendar-time-zone (eval chinese-calendar-time-zone))
(calendar-daylight-time-offset
chinese-calendar-daylight-time-offset)
(calendar-standard-time-zone-name
chinese-calendar-standard-time-zone-name)
(calendar-daylight-time-zone-name
chinese-calendar-daylight-time-zone-name)
(calendar-calendar-daylight-savings-starts
chinese-calendar-daylight-savings-starts)
(calendar-daylight-savings-ends
chinese-calendar-daylight-savings-ends)
(calendar-daylight-savings-starts-time
chinese-calendar-daylight-savings-starts-time)
(calendar-daylight-savings-ends-time
chinese-calendar-daylight-savings-ends-time))
(floor
(calendar-absolute-from-astro
(lunar-new-moon-on-or-after
(calendar-astro-from-absolute d))))))
(defvar chinese-year-cache
'((1989 (12 726110) (1 726139) (2 726169) (3 726198) (4 726227) (5 726257)
(6 726286) (7 726316) (8 726345) (9 726375) (10 726404) (11 726434))
(1990 (12 726464) (1 726494) (2 726523) (3 726553) (4 726582) (5 726611)
(5.5 726641) (6 726670) (7 726699) (8 726729) (9 726758) (10 726788)
(11 726818))
(1991 (12 726848) (1 726878) (2 726907) (3 726937) (4 726966) (5 726995)
(6 727025) (7 727054) (8 727083) (9 727113) (10 727142) (11 727172))
(1992 (12 727202) (1 727232) (2 727261) (3 727291) (4 727321) (5 727350)
(6 727379) (7 727409) (8 727438) (9 727467) (10 727497) (11 727526))
(1993 (12 727556) (1 727586) (2 727615) (3 727645) (3.5 727675) (4 727704)
(5 727734) (6 727763) (7 727793) (8 727822) (9 727851) (10 727881)
(11 727910))
(1994 (12 727940) (1 727969) (2 727999) (3 728029) (4 728059) (5 728088)
(6 728118)